<?php

use yii\db\Migration;

class m000003_000001_create_user extends Migration
{
    public function safeUp()
    {
        $this->createTable('{{%user}}', [
            'id' => $this->primaryKey(),
            'username' => $this->string(128)->notNull()->comment('登录用户名'),
            'password' => $this->string(512)->notNull()->comment('登录密码'),
            'auth_key' => $this->string(32)->comment('Cookie验证字符串'),
            'status' => $this->integer()->notNull()->comment('状态'),
            'create_time' => $this->integer()->notNull()->comment('创建时间'),
        ]);
        $this->createIndex('user1_idx', '{{%user}}', ['username']);
        $this->batchInsert('{{%key_map}}', ['t', 'k', 'v'], [
            ['user_status', 1, '正常'],
            ['user_status', 9, '暂停'],
            ['user_status', 0, '删除'],
        ]);
    }

    public function down()
    {
        $this->delete('{{%key_map}}', ['t' => 'user_status']);
        $this->dropTable('{{%user}}');
    }
}
